home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
ibink10.arc
/
IBINK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-03-09
|
6KB
|
204 lines
/* IBINK.C - Author: David Bennett (1:280/307) - Date: 3/7/91 - Version: 1.0
*
* Compiled Using Borland C++ (Should compile fine under Turbo C 2.0)
*
* Convert Arcmail to Binkley type .FLO file entries.
*
* .MSG requirements
*
* .MSG must be addressed to "ARCMail"
* attached flag must be true
* local flag must be true
* if hold is set the extension becomes .HLO (precedence over crash)
* if crash is set the extension becomes .CLO (precedence over direct)
* if direct is set the extention becomes .DLO
* if killsent is set then .MSG is unlinked after .?LO is updated
*
* Note: In outbound .?LO files a '^' preceding a filename deletes that
* file after sending. A '#' preceding the name truncates the name
* to 0. I am using '#' here in hopes that IMAIL will check and
* not create duplicate outbound archive names.
*
* Ideas for improvments & enhancments:
*
* - Move this code into Binkley. Then Binkley could support ARCMail
* attaches directly.
*
* - Add support for BINKLEY.CFG so you don't have to specify the
* directories on the command line.
*
* - Add logging.
*/
#include <dir.h>
#include <dos.h>
#include <stdio.h>
#include <string.h>
#include "fidoadr.h"
#include "ibink.h"
char *title="\nIBINK - Author: David Bennett (1:280/307) - Date: 3/7/91 - Version: 1.0\n\n";
char *usage= \
" Convert's IMAIL generated ARCMail attaches to Binkley .?LO\n" \
"\n" \
"Usage: IBINK <hudson netmail dir> <binkley base outbound dir>\n" \
"\n" \
"Where:\n" \
"\n" \
" <hudson netmail dir> - Is the directory that 'IMAIL SCAN'\n" \
" creates the ARCMail attaches (###.MSG files) in.\n" \
"\n" \
" <binkley base outbound dir> - Is the base (zone 1) outbound\n" \
" specification for BinkleyTerm.\n" \
"\n" \
"- Multi-Zone attaches are supported. OUTBOUND.### zone directories\n" \
" are created if they don't exist.\n" \
"\n" \
"- It is recommended that you supply a different directory for IMAIL's\n" \
" outbound specification than your Binkley outbound directory.\n";
char inspec[MAXPATH]; /* Input directory spec (netmail) */
char inpath[MAXPATH]; /* Input path (netmail) */
char outpath[MAXPATH]; /* Output base path (bink outbound) */
char inname[MAXPATH]; /* Input filename (netmail .MSG) */
char outname[MAXPATH]; /* Output filename (outbound .?LO) */
char tmpname[MAXFILE]; /* Temporary name to check .MSG file */
char tmpstr[MAXPATH]; /* Temporary throw away area for fn_split() */
char hexstr[MAXFILE]; /* Hex string for outbound dir filenames */
char outext[MAXEXT]; /* Output extention (.FLO .CLO .HLO) */
FIDOHEADER fidohdr; /* .MSG header */
FIDOADR destadr=DEF_FIDOADR; /* Destination address */
char msgtxt[0x4000]; /* 16k for message text, more than enough */
void main(int argc, char **argv)
{
int i, test;
FILE *infile, *outfile;
char *p;
struct ffblk fb;
fputs(title, stderr);
if (argc != 3) {
fputs(usage, stderr);
exit(1);
}
/*
* Add '\' to end of the netmail path if not there.
*/
strcpy(inpath, argv[1]);
if (inpath[strlen(inpath)-1] != '\\') strcat(inpath, "\\");
strcpy(inspec, inpath);
strcat(inspec, "*.MSG");
/*
* Remove the '\' from the end of the outbound path if it is there
* so the .zzz zone extension can be added if necessary.
*/
strcpy(outpath, argv[2]);
p = &(outpath[strlen(outpath)-1]);
if (*p == '\\') *p = '\0';
if (!findfirst(inspec, &fb, 0)) do {
strcpy(inname, inpath);
strcat(inname, fb.ff_name);
/*
* Check for valid filename and open the .MSG file
*/
fnsplit(inname, tmpstr, tmpstr, tmpname, tmpstr);
if (atoi(tmpname)) infile = fopen(inname, "rb");
else infile = NULL;
if (infile) {
/*
* Read the Fido header
*/
if (fread(&fidohdr, sizeof(FIDOHEADER), 1, infile) == 1) {
test = stricmp(fidohdr.to, "arcmail");
test = (test && fidohdr.attr.attached && fidohdr.attr.local);
if (test) {
/*
* Calculate file attach extension.
*/
if (fidohdr.attr.hold) strcpy(outext, ".HLO");
else if (fidohdr.attr.crash) strcpy(outext, ".CLO");
else if (fidohdr.attr.direct) strcpy(outext, ".DLO");
else strcpy(outext, ".FLO");
/*
* Read message text
*/
fread(msgtxt, sizeof(msgtxt), 1, infile);
/*
* Check for Multi-zone address
*/
memset(&destadr, 0, sizeof(FIDOADR));
p = strstr(msgtxt, "\x01INTL");
if (p) {
p = strchr(p, ' ');
strtok(++p, " ");
fidoadr_split(p, &destadr);
}
else {
destadr.net = fidohdr.dest_net;
destadr.node = fidohdr.dest;
}
/*
* Status display
*/
fidoadr_merge(tmpstr, &destadr);
printf("ARCMail attach to (%s)\t -> ", tmpstr);
/*
* Create/Update correct outbound directory
* (C:\BT\OUTBOUND.zzz)
*/
strcpy(outname, outpath);
if (destadr.zone > 1) {
sprintf(hexstr, "\.%03X", destadr.zone);
strcat(outname, hexstr);
}
/*
* Make outbound directory or fail harmlessly.
*/
mkdir(outname);
/*
* add ?LO file name.
*/
strcat(outname, "\\");
hexadr_merge(hexstr, destadr.net, destadr.node);
strcat(outname, hexstr);
strcat(outname, outext);
/*
* Status display
*/
printf("%s\n", outname);
/*
* Create/Append the file attach.
*/
outfile = fopen(outname, "at");
if (outfile) {
fprintf(outfile, "#%s\n", strupr(fidohdr.subj));
fclose(outfile);
}
}
fclose(infile);
if (fidohdr.attr.killsent) unlink(inname);
}
}
} while (!findnext(&fb));
}